package com.kaoshi.management.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kaoshi.management.pojo.XtSettingsInformationManagement;
import com.kaoshi.management.mapper.XtSettingsInformationManagementMapper;
import com.kaoshi.management.service.XtSettingsInformationManagementService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author author
 * @since 2024-10-30
 */
@Service
public class XtSettingsInformationManagementServiceImpl extends ServiceImpl<XtSettingsInformationManagementMapper, XtSettingsInformationManagement> implements XtSettingsInformationManagementService {

    @Override
    public Page<XtSettingsInformationManagement> getPage(Integer current, Integer limit, XtSettingsInformationManagement xtSettingsInformation) {
        Page<XtSettingsInformationManagement> page = new Page<>(current, limit);

        LambdaQueryWrapper<XtSettingsInformationManagement> wrapper = new LambdaQueryWrapper<>();

        // 模糊查询
        if (xtSettingsInformation.getArticletitle() != null) {
            wrapper.like(XtSettingsInformationManagement::getArticletitle, xtSettingsInformation.getArticletitle());
        }

        // 区间查询，可以根据需要添加其他字段
        if (xtSettingsInformation.getStartDate() != null && xtSettingsInformation.getEndDate() != null) {
            // 假设 XtSettingsInformationManagement 有一个获取日期的方法 getDate()
            wrapper.between(XtSettingsInformationManagement::getOperationtime, xtSettingsInformation.getStartDate(), xtSettingsInformation.getEndDate());
        }

        return baseMapper.selectPage(page, wrapper);
    }
}
